package itdfq.ydd.Structural_Patterns.xiangyuan;

import java.util.ArrayList;

/**
 * @Author GocChin
 * @Date 2021/4/20 18:53
 * @Blog: itdfq.com
 * @QQ: 909256107
 */
public class WeiqiFactory {
    private ArrayList arrayList = new ArrayList();
    private  int temp = 0;
    public WeiqiFactory(){
        BackWeiqi backWeiqi = new BackWeiqi("黑色");
        arrayList.add(backWeiqi);
        WhiteWeiqi whiteWeiqi = new WhiteWeiqi("白色");
        arrayList.add(whiteWeiqi);
    }
    public Weiqi getWeiqi(String color){
        if (color.equals("黑色")){
            temp++;
            return (Weiqi) arrayList.get(0);
        }else if (color.equals("白色")){
            temp++;
            return (Weiqi) arrayList.get(1);
        }
        else {
            return null;
        }
    }
    public int getTemp(){
        return temp;
    }
    public int getTotalWeiqi(){
        return arrayList.size();
    }
}
